
	document.write( '<form id="oForm"><input Class="userData" style="DISPLAY: none; HEIGHT: 22px; WIDTH: 26px" ID="oInput"></form><IE:clientCaps id="ExculpateRate"></IE:clientCaps>')
	var userData=oForm.oInput


function loadLabelData(strType,screenWidth,screenHeight){
//strType="打印设计"/"打印预览"
//装入数据
//返回:无

	//设置最大的Label的宽高
	result.style.width =screenWidth-5	
	result.style.height =screenHeight-25

	//从缓存中取出页面设置信息
	var setformat=LoadUserData("billprint",BillName)
	
	if (setformat!=""){
		var oXML1=new ActiveXObject("Microsoft.XMLDOM")
		oXML1.async="false"
		oXML1.loadXML("<root>"+setformat+"</root>")
		topwindage=parseFloat(oXML1.documentElement.childNodes.item(0).text)
		leftwindage=parseFloat(oXML1.documentElement.childNodes.item(1).text)
		printformat=oXML1.documentElement.childNodes.item(2).text
		//缓存中纸张的宽高单位为mm
		repWidth=parseFloat(oXML1.documentElement.childNodes.item(3).text)
		repHeight=parseFloat(oXML1.documentElement.childNodes.item(4).text)
		printCopys=parseInt(oXML1.documentElement.childNodes.item(5).text)
		offsetAdjust=parseFloat(oXML1.documentElement.childNodes.item(6).text)
	}
	else {
		//缺省值
		topwindage=0
		leftwindage=0
		printformat="套打"
		repWidth=210
		repHeight=297
		printCopys=3
		offsetAdjust=0
	}
	//缺省的页面信息已预给
	var pxRatemm=3.78	//*(297-offsetAdjust)/297
	//------------
	if (printCopys==0)printCopys=1

	//装入数据,计算页数和节点数
	var oXML=new ActiveXObject("Microsoft.XMLDOM")
	oXML.async ="false"
	oXML.loadXML(SendParameter)
	if(strType=="打印设计") {
		number=1 //打印设计是只能有一页
	}
	else {
		//页数，它是第一级子节点的个数除以每页打印的份数	
		number=Math.ceil(oXML.documentElement.childNodes.length/printCopys)
	}
	var oneNodeNumber=oXML.documentElement.childNodes.length  //第一级子节点的个数
	lastnodenumber=oXML.documentElement .childNodes.item (0).childNodes .length//第二级子节点的个数
	//-------------
	var newDiv
	var newDivtop=50 //缺省的第一个DIV top
	
	//装入缓存中格式的值
	var strAll=LoadUserData("node",BillName) 
	//strAll=""
	if(isSpace(strAll)==false){
		var oX=new ActiveXObject("Microsoft.XMLDOM")
		oX.async="false";	
		oX.loadXML("<root>" +strAll+"</root>")
	}
	//--------
	//sadfsd
	//清空,以便刷新时正确
	result.innerHTML=""
	
	//打印页数循环
	for (var i=0;i<number;i++){
		newDiv=document.createElement("div") 
		newDiv.style.borderTopStyle="solid"
		newDiv.style.borderTopColor="DarkGreen"
		newDiv.style.borderTopWidth=2	
		newDiv.style.borderLeftStyle="solid"
		newDiv.style.borderLeftColor="DarkGreen"
		newDiv.style.borderLeftWidth=2	
		newDiv.style.borderRightStyle="solid"
		newDiv.style.borderRightColor="DarkGreen"
		newDiv.style.borderRightWidth=2	
		newDiv.style.borderBottomStyle="solid"
		newDiv.style.borderBottomColor="DarkGreen"
		newDiv.style.borderBottomWidth=2	
		newDiv.style.position="absolute"
		newDiv.style.width=repWidth*pxRatemm
		if(strType=="打印设计") {
			newDiv.style.height=repHeight*pxRatemm/printCopys
		}
		else {
			newDiv.style.height=repHeight*pxRatemm
		}
		newDiv.style.backgroundColor="White"
		//newDiv.style.pageBreakAfter="always"
		if ((screenWidth-repWidth*pxRatemm)*0.5-5>0){
			newDiv.style.left=(screenWidth-repWidth*pxRatemm)*0.5-5
		}
		if ((screenWidth-repWidth*pxRatemm)*0.5-5<=0){
			newDiv.style.left=0
		}
	
		newDiv.style.top=newDivtop
		if(strType=="打印设计") {
			newDivtop=newDivtop+repHeight*pxRatemm/printCopys+20	
		}
		else {
			newDivtop=newDivtop+repHeight*pxRatemm+20	
		}
		
	
		result.insertAdjacentElement("beforeEnd",newDiv)
		var spanTop=20	//缺省的第一个方块top
		//每页打印信封份数循环
		if(strType=="打印设计") printCopys=1
		//每页打印份数循环
		for(var copys=0;copys<printCopys;copys++){

			//如果数据已用完
			if(i*printCopys+copys>=oneNodeNumber) break
			if (tableHtml!="") {
				//计算背景
				newDiv.innerHTML=newDiv.innerHTML+tableHtml
				var oBillStyle=document.all.item("billstyle")
				var curBillStyle  //当前背景对象
				if (oBillStyle.length>0){
					curBillStyle=oBillStyle[oBillStyle.length-1]
				}
				else {
					curBillStyle=oBillStyle
				}
				curBillStyle.style.top=copys*repHeight*pxRatemm/printCopys
			}
			//------------------
			
			//每页里面的标签循环
			for (var j=0;j<lastnodenumber;j++){
				if(strType=="打印设计") {
					newSpan=document.createElement("IE:piece") 
					newSpan.id="fcsoft_node"
					newSpan.style.position="absolute"		
					newSpan.innerText=oXML.documentElement.childNodes.item (0).childNodes.item(j).tagName
				}
				else { //strType=="打印预览"
					newSpan=document.createElement("span") 
					newSpan.style.position="absolute"
					newSpan.id="fcsoft_node"
					newSpan.innerText=oXML.documentElement .childNodes.item (i*printCopys+copys).childNodes.item(j).text
				}
				newDiv.insertAdjacentElement("beforeEnd",newSpan)
				if(isSpace(strAll)==false){
					//装入已存好的信息
					newSpan.style.left=oX.documentElement.childNodes(j).childNodes.item(0).text
					newSpan.style.top=parseInt(oX.documentElement.childNodes(j).childNodes.item (1).text)+repHeight*pxRatemm*copys/printCopys
					if (oX.documentElement.childNodes(j).childNodes.item (2).text!=""){
						newSpan .style.width=parseInt(oX.documentElement.childNodes(j).childNodes.item (2).text)
					}	
					else{
						newSpan .style.width=""
					}	
					newSpan .style.letterSpacing=oX.documentElement.childNodes(j).childNodes.item (3).text
					newSpan .style.fontSize=oX.documentElement.childNodes(j).childNodes.item (4).text
					newSpan .style.fontFamily=oX.documentElement.childNodes(j).childNodes.item (5).text
					newSpan .style.fontWeight=oX.documentElement.childNodes(j).childNodes.item (6).text	
					newSpan .style.textDecoration=oX.documentElement.childNodes(j).childNodes.item (7).text	
					newSpan .style.fontStyle=oX.documentElement.childNodes(j).childNodes.item (8).text		
					newSpan .style.color=oX.documentElement.childNodes(j).childNodes.item (9).text
					newSpan .style.textAlign=oX.documentElement.childNodes(j).childNodes.item (10).text
				}
				else {
					//缺省的方块信息					
					spanTop=spanTop+20
					newSpan.style.top=spanTop
					newSpan .style.left=100
					newSpan.style.letterSpacing=1
					newSpan .style.fontSize=15
					newSpan .style.fontFamily="serif"
					newSpan .style.fontWeight="normal"	
					newSpan .style.textDecoration="none"		
					newSpan .style.fontStyle="normal"		
					newSpan .style.color="black"
					newSpan .style.textAlign="left"
				
				}
					
			}//每页里面的标签循环结束
		}	//每页打印信封份数循环结束	
	}//每页循环结束	
	
}
	
function PrintDesign() {	
 	//调用打印设计功能
	var BillDesign=new Array()
		BillDesign[0]=tableHtml
		BillDesign[1]=BillName
		BillDesign[2]=SendParameter
		BillDesign[5]=strPageSet
		BillDesign[6]=strPageAll
		/*
		//3,4空缺
		BillDesign[5]=repWidth
		BillDesign[6]=repHeight
		BillDesign[7]=printCopys
		BillDesign[8]=topOffset
		BillDesign[9]=leftOffset
		BillDesign[10]=printformat
		BillDesign[11]=offsetAdjust
		*/
	var dialogStyle="dialogHeight:"+ExculpateRate.height+"px;dialogWidth:"+ExculpateRate.width+"px;dialogTop:0px;dialogLeft:0px;status:no;scroll:no"
	var printReturn=window.showModalDialog("/webprint/billprint/printdesign.htm",BillDesign,dialogStyle)
}

function PrintPreview(isPrint) {
	//进入打印预览
	var BillDesign=new Array()
	BillDesign[0]=tableHtml
	BillDesign[1]=BillName	
	BillDesign[2]=SendParameter
	BillDesign[3]=ExculpateRate.width	
	BillDesign[4]=ExculpateRate.height
	BillDesign[5]=strPageSet
	BillDesign[6]=strPageAll
	BillDesign[7]=isPrint // and by amon 是否直接打印
	var h = ExculpateRate.height;
	var w = ExculpateRate.width;
	if(isPrint == true)
	{
		h = 0;
		w = 0;
	}
	var dialogStyle="dialogHeight:"+h+"px;dialogWidth:"+w+"px;dialogTop:0px;dialogLeft:0px;status:no;scroll:no"
	var printReturn=window.showModalDialog("/webprint/billprint/printpreview.htm",BillDesign,dialogStyle)
}
function PrintPreview1() {
	//从打印设计界面进入打印预览
	var BillDesign=new Array()
	BillDesign[0]=tableHtml
	BillDesign[1]=BillName	
	BillDesign[2]=SendParameter
	BillDesign[3]=ExculpateRate.width	
	BillDesign[4]=ExculpateRate.height
	BillDesign[5]=""
	BillDesign[6]=""

	var dialogStyle="dialogHeight:"+ExculpateRate.height+"px;dialogWidth:"+ExculpateRate.width+"px;dialogTop:0px;dialogLeft:0px;status:no;scroll:no"
	var printReturn=window.showModalDialog("printpreview.htm",BillDesign,dialogStyle)
}

//////////////////////////////////////////////////////////////////////上面程序是billprint.htm页面中的 
function ContDec(sValue,sPointNum) {
	var dblValue=parseFloat(sValue)
	if (isNaN(dblValue)) return sValue
	var iPointNum=parseInt(sPointNum)
	if (isNaN(iPointNum)) iPointNum=0
	if (iPointNum>9) iPointNum=9
	var dbl1=Math.round(dblValue*Math.pow(10,iPointNum))/Math.pow(10,iPointNum)
	var s1=dbl1.toString()
	if (s1.indexOf(".") == -1) {
		var s2="000000000000000"
		s1=s1+"."+s2.substring(0,iPointNum)
	}
	if (right(s1,1)==".")
		s1=s1.substring(s1.length-1,s1.length)
	return s1
}

function SaveUserData(Main,Sub,strContent){
//存到数据缓存中
//Main为主key 如"List"
//Sub 为子key 如"CustomerFlag"
//strContent 为要存入的内容
//无返回
	try {
		userData.setAttribute(Main+userData.value,strContent)
		userData.save(Sub+userData.value)
	}
	catch (e){}
}

function LoadUserData(Main,Sub){
//从数据缓存中装入到变量中
//Main为主key 如"List"
//Sub 为子key 如"CustomerFlag"
//返回取出的内容
	userData.load(Sub+userData.value)  
	var sTmp=userData.getAttribute(Main+userData.value)
	if (sTmp==null) sTmp=""
	return sTmp

}
/*
function ShowErr(sErr)
{
//显示错误信息
		var sErr1=left(sErr,sErr.indexOf("</root>")+7)
		var oXml=new ActiveXObject("Microsoft.XMLDOM")
		oXml.async ="false"
		oXml.loadXML(sErr1)
		//alert(sErr)
		alert(oXml.documentElement.text  )	 
}  

function showMenu() {
   //this function will position and display a nested div that acts like a menu
     
   whichDiv=event.srcElement;
   s=whichDiv.innerHTML
		var oClick=window.event.srcElement
		if (oClick.tagName=="DIV") oClick=oClick.parentNode
		if (oClick.tagName=="TD") oClick=oClick.parentNode
		if (oClick.tagName=="TR") curRow= oClick.sectionRowIndex-1
   
//   alert(curRow)
   arr[1]=curRowXml(curRow,strX) // event.srcElement.parentNode.parentNode.childNodes(0).childNodes(0).innerText
    
   menu1.style.posLeft=event.clientX+document.body.scrollLeft;
   menu1.style.posTop=event.clientY+document.body.scrollTop;
   menu1.style.display="";
   menu1.setCapture();
}

function toggleMenu() {   
   el=event.srcElement;
   if (el.className=="menuItem") {
      el.className="highlightItem";
        
   } else if (el.className=="highlightItem") {
      el.className="menuItem";
   }
}
function contextTwice() {
   if (event.srcElement==whichDiv)
     showMenu();
}

 

function curRowXml(curRow,strX){
//返回strX中curRow的节点串
//curRow当前行,strX源串
  oXML.async="false";
  oXML.loadXML('<root>' +strX+'</root>')
	var o=oXML.XMLDocument.childNodes.item(0).childNodes.item(curRow)
	if (o.getAttribute("flngCustomerID")!="0" && o.getAttribute("flag")=="" && o.tagName=="Customer")
	{
		if (navigator.onLine)
		{
			var	s1=SendHttp("public.asp?key=getcustomerbyid","<No>"+o.getAttribute("flngCustomerID")+"</No>")
			return s1
		}
		else
		{
			alert("脱机模式下不能修改(但可以删除)在数据库中的客户或供应商!请联上网后再使用.")
			return oXML.XMLDocument.childNodes.item(0).childNodes.item(curRow).xml
		}	
	}
	if (o.getAttribute("flngSupplyID")!="0" && o.getAttribute("flag")=="" && o.tagName=="Supply")
	{
		if (navigator.onLine)
		{
			var	s1=SendHttp("public.asp?key=getsupplybyid","<No>"+o.getAttribute("flngSupplyID")+"</No>")
			return s1
		}
		else
		{
			alert("脱机模式下不能修改(但可以删除)在数据库中的客户或供应商!请联上网后再使用.")
			return oXML.XMLDocument.childNodes.item(0).childNodes.item(curRow).xml
		}	
	}

	var s1=oXML.XMLDocument.childNodes.item(0).childNodes.item(curRow).xml
	return s1  
}

function RemoveRoot(strX){
  //去掉根结点标记
  if (strX.length>15)
		{
			strX=strX.substring(6,strX.length-9)
			return strX
		}
	else
		{
			return ""
		}	
}


//函数名：chksafe
//功能介绍：检查是否含有"'",'\\',"/"
//参数说明：要检查的字符串
//返回值：0：是  1：不是
function chksafe(a)
{	
	return 1;
	fibdn = new Array ("'" ,"\\", "、", ",", ";", "/");
	i=fibdn.length;
	j=a.length;
	for (ii=0;ii<i;ii++)
	{	for (jj=0;jj<j;jj++)
		{	temp1=a.charAt(jj);
			temp2=fibdn[ii];
			if (tem';p1==temp2)
			{	return 0; }
		}
	}
	return 1;
	
}

//函数名：chkspc
//功能介绍：检查是否含有空格
//参数说明：要检查的字符串
//返回值：0：是  1：不是
function chkspc(a)
{
	var i=a.length;
	var j = 0;
	var k = 0;
	while (k<i)
	{
		if (a.charAt(k) != " ")
			j = j+1;
		k = k+1;
	}
	if (j==0)
	{
		return 0;
	}
	
	if (i!=j)
	{ return 2; }
	else
	{
		return 1;
	}
}


//函数名：chkemail
//功能介绍：检查是否为Email Address
//参数说明：要检查的字符串
//返回值：0：不是  1：是
function chkemail(a)
{	var i=a.length;
	var temp = a.indexOf('@');
	var tempd = a.indexOf('.');
	if (temp > 1) {
		if ((i-temp) > 3){
			
				if ((i-tempd)>0){
					return 1;
				}			
		}
	}
	return 0;
}

//opt1 小数     opt2   负数
//当opt2为1时检查num是否是负数
//当opt1为1时检查num是否是小数
//返回1是正确的，0是错误的
function chknbr(num,opt1,opt2)
{
	var i=num.length;
	var staus;
//staus用于记录.的个数
	status=0;
	if ((opt2!=1) && (num.charAt(0)=='-'))
	{
		//alert("You have enter a invalid number.");
		return 0;
	
	}
//当最后一位为.时出错
	if (num.charAt(i-1)=='.')
	{
		//alert("You have enter a invalid number.");
		return 0;
	}

	for (j=0;j<i;j++)
	{
		if (num.charAt(j)=='.')
		{
			status++;
		}
		if (status>1) 
		{
		//alert("You have enter a invalid number.");
		return 0;		
		}
		if (num.charAt(j)<'0' || num.charAt(j)>'9' )
		{
			if (((opt1==0) || (num.charAt(j)!='.')) && (j!=0)) 
			{
				//alert("You have enter a invalid number.");
				return 0;
			}
		}
	}
	return 1;
}

//函数名：chkdate
//功能介绍：检查是否为日期
//参数说明：要检查的字符串
//返回值：0：不是日期  1：是日期
function chkdate(datestr)
{
	var lthdatestr
	if (datestr != "")
		lthdatestr= datestr.length ;
	else
		lthdatestr=0;
		
	var tmpy="";
	var tmpm="";
	var tmpd="";
	//var datestr;
	var status;
	status=0;
	if ( lthdatestr== 0)
		return 0

	
	for (i=0;i<lthdatestr;i++)
	{	if (datestr.charAt(i)== '-')
		{
			status++;
		}
		if (status>2)
		{
			//alert("Invalid format of date!");
			return 0;
		}
		if ((status==0) && (datestr.charAt(i)!='-'))
		{
			tmpy=tmpy+datestr.charAt(i)
		}
		if ((status==1) && (datestr.charAt(i)!='-'))
		{
			tmpm=tmpm+datestr.charAt(i)
		}
		if ((status==2) && (datestr.charAt(i)!='-'))
		{
			tmpd=tmpd+datestr.charAt(i)
		}

	}
	year=new String (tmpy);
	month=new String (tmpm);
	day=new String (tmpd)
	//tempdate= new String (year+month+day);
	//alert(tempdate);
	if ((tmpy.length!=4) || (tmpm.length>2) || (tmpd.length>2))
	{
		//alert("Invalid format of date!");
		return 0;
	}
	if (!((1<=month) && (12>=month) && (31>=day) && (1<=day)) )
	{
		//alert ("Invalid month or day!");
		return 0;
	}
	if (!((year % 4)==0) && (month==2) && (day==29))
	{
		//alert ("This is not a leap year!");
		return 0;
	}
	if ((month<=7) && ((month % 2)==0) && (day>=31))
	{
		//alert ("This month is a small month!");
		return 0;
	
	}
	if ((month>=8) && ((month % 2)==1) && (day>=31))
	{
		//alert ("This month is a small month!");
		return 0;
	}
	if ((month==2) && (day==30))
	{
		//alert("The Febryary never has this day!");
		return 0;
	}
	
	return 1;
}

//函数名：fucPWDchk
//功能介绍：检查是否含有非数字或字母
//参数说明：要检查的字符串
//返回值：0：含有 1：全部为数字或字母
function fucPWDchk(str)
{
  var strSource ="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  var ch;
  var i;
  var temp;
  
  for (i=0;i<=(str.length-1);i++)
  {
  
    ch = str.charAt(i);
    temp = strSource.indexOf(ch);
    if (temp==-1) 
    {
     return 0;
    }
  }
  if (strSource.indexOf(ch)==-1)
  {
    return 0;
  }
  else
  {
    return 1;
  } 
}

function jtrim(str)
{     while (str.charAt(0)==" ")
          {str=str.substr(1);}      
     while (str.charAt(str.length-1)==" ")
         {str=str.substr(0,str.length-1);}
     return(str);
}


//函数名：fucCheckNUM
//功能介绍：检查是否为数字
//参数说明：要检查的数字
//返回值：1为是数字，0为不是数字
function fucCheckNUM(NUM)
{
	var i,j,strTemp;
	strTemp="0123456789";
	if ( NUM.length== 0)
		return 0
	for (i=0;i<NUM.length;i++)
	{
		j=strTemp.indexOf(NUM.charAt(i));	
		if (j==-1)
		{
		//说明有字符不是数字
			return 0;
		}
	}
	//说明是数字
	return 1;
}

//函数名：fucCheckTEL
//功能介绍：检查是否为电话号码
//参数说明：要检查的字符串
//返回值：1为是合法，0为不合法
function fucCheckTEL(TEL)
{
	var i,j,strTemp;
	strTemp="0123456789-()# ";
	for (i=0;i<TEL.length;i++)
	{
		j=strTemp.indexOf(TEL.charAt(i));	
		if (j==-1)
		{
		//说明有字符不合法
			return 0;
		}
	}
	//说明合法
	return 1;
}

//函数名：fucCheckLength
//功能介绍：检查字符串的长度
//参数说明：要检查的字符串
//返回值：长度值
function fucCheckLength(strTemp)
{
	var i,sum;
	sum=0;
	for(i=0;i<strTemp.length;i++)
	{
		if ((strTemp.charCodeAt(i)>=0) && (strTemp.charCodeAt(i)<=255))
			sum=sum+1;
		else
			sum=sum+2;
	}
	return sum;
}


//梅琪于10.09日从report.js中转移来的
//将基本资料装入combox中   参数：表名   字段
function loadDataToCbo(strTable,strField) {
	var strReturn=SendHttp("getJbclField.asp","<No1>" + strTable + "</No1><No2>" + strField + "</No2>")
	var oXML1=new ActiveXObject("Microsoft.XMLDOM")
	oXML1.async="false";
	oXML1.loadXML('<root>' + strReturn + '</root>')
	cbo1.options.length=0
	
	cboBlank=document.createElement("option")
	cboBlank.value="　" //加上此段下拉项多出
	cboBlank.text="　"
	cbo1.add(cboBlank)

	var initCboValue=cbo1.value
	for (i=0 ;i<=oXML1.documentElement.childNodes.length-1;i++) {
		strFieldValue=oXML1.documentElement.childNodes.item(i).getAttribute(strField)
		cboTarget=document.createElement ("option")
		cboTarget.value=strFieldValue //??如何得到cbo1的条件与结果值
		cboTarget.text=strFieldValue
		if (i==0) {
			cboTarget.selected=1
		}
		if (cboTarget.value!=initCboValue){
			cbo1.add(cboTarget)		
		}				
	}	
	cbo1.value=""
}
*/

//梅琪于10.12从report.js转移来
function isSpace(strMain){

	strComp=strMain

	if (strComp=="　" || strComp=="" || strComp==" " || strComp==null || strComp.length==0 ) { 
		return true
	}
	else
	{
			return false
	}
}
//------------------------------------------------
//字符串实用函数
function getFront(mainStr,searchStr){
	foundOffset=mainStr.indexOf(searchStr)
	if (foundOffset==-1) {
		return null
	}
	return mainStr.substring(0,foundOffset)
}
function getEnd(mainStr,searchStr) {
	foundOffset=mainStr.indexOf(searchStr)
	if (foundOffset==-1) {
		return null
	}
	return mainStr.substring(foundOffset+searchStr.length,mainStr.length)
}

function insertString(mainStr,searchStr,insertStr) {
	var front=getFront(mainStr,searchStr)
	var end=getEnd(mainStr,searchStr)
	if (front!=null && end!=null) {
		return front+insertStr+searchStr+end
	}
	return null
}

function deleteString(mainStr,deleteStr) {
	return replaceString(mainStr,deleteStr,"")
}					

function replaceString(mainStr,searchStr,replaceStr) {
//代替字符串
//mainStr为源串  searchStr为要查找的串  replaceStr为要改为的串
//返回替换后的串
	var front=getFront(mainStr,searchStr)
	var end=getEnd(mainStr,searchStr)
	if (front!=null && end!=null) {
		return front+replaceStr+end
	}
	return null
}		

function left(mainStr,lngLen) {
	if (lngLen>0) {
		return mainStr.substring(0,lngLen)
	}
	else
	{
		return null
	}
}

function right(mainStr,lngLen) {
//	alert(mainStr.length)
	if (mainStr.length-lngLen>=0 && mainStr.length>=0 && mainStr.length-lngLen<=mainStr.length) {
		return mainStr.substring(mainStr.length-lngLen,mainStr.length)
	}
	else
	{
		return null
	}
}

//滤掉左右空格
function trim(strMain) {
	if (strMain==null) return ""
  var str1=strMain
	
	//去掉回车符
  var ascMain=strMain.charCodeAt(strMain.length-1)
	if (ascMain==32) str1=left(strMain,strMain.length-1)

	if (str1==null) return ""

  for (var i=0;i<=str1.length-1;i++) {
       var mychar=str1.charAt(i);
       if ((mychar!=" ") && (mychar!="　")) {
           str1=str1.substring(i,str1.length);
           break;
           } 
      }

  for (var i=str1.length-1;i>0;i--) {
      var mychar=str1.charAt(i);
      if ((mychar!=" ")  && (mychar!="　")) {
         str1=str1.substring(0,i+1);
         break;
      }
  }

  return str1;
}

//在日期数据将加上20或19
function DateTo8(strDate){
	var sDate=trim(strDate)
	if (sDate.length<=8)
	{
		var sTmp=parseInt(left(sDate,2))
		if (sTmp<38) 
			return "20" +sDate
		else
			return "19" +sDate
	}	
	return strDate	
}
//求当前日期
function curDate() {
	var dDate=new Date()
	var s1=""+dDate.getYear()
	var s2=dDate.getMonth()+1
	if (s2<10) 
		s2="0"+s2
	else
		s2=""+s2
			
	var s3=dDate.getDate()
	if (s3<10) 
		s3="0"+s3
	else
		s3=""+s3

	return s1+"-"+s2+"-"+s3 
}
/*
function Format(num,dotLen) {
//将num按小数位为dotLen来进行格式化  如无小数位参数则为2位小数
//
	var dot=0
	var num1=0
	if (typeof dotLen=="undefined" || dotLen==null ) 
		dot=2
	else
		dot=dotLen
		
	if (isNaN(parseFloat(num)))
		return 0
	else
		num1=parseFloat(num)
		
	var n1=Math.pow(10,dot)
	if (n1==0) 
		var iValue= Math.round(num1)
	else
		var iValue=	Math.round(num1*n1)/n1
		
  var sValue = iValue.toString();
  if (sValue.indexOf(".") == -1)
  {
      sValue = sValue + ".00";
  }
  else
  {
      if (sValue.indexOf(".") == sValue.length - 1)
      {
          sValue = sValue + "00";
      }
      else if (sValue.indexOf(".") == sValue.length - 2)
      {
          sValue = sValue + "0";
      }
  }

	return sValue		
}

//------------------------------------------------
function PartXml(sXml,StartPos,len)
{
//取指定长度的Xml串
//StartPos开始位置从0始, len为取的长度
		var oXml=new ActiveXObject("Microsoft.XMLDOM")
		oXml.async="false";
		oXml.loadXML(sXml)
		var sReturn=""
		for (var i=StartPos;i<StartPos+len;i++)
		{
			if (i<oXml.documentElement.childNodes.length)
				sReturn=sReturn+oXml.documentElement.childNodes.item(i).xml
		}
		return sReturn
}


//------------------------------------------------
//错误处理
function xslErr(error) {
	var s=""
	for (var i=1;i<error.linepos;i++) {
		s+=""
	}
	r="<font face=Verdana size=2><font size=4>XML 装入错误 "+error.url+"</font>"+"<P><B>"+error.reason+"</B></P></font>"
	if (error.line>0)
		s+="<font size=3><XMP>"+"在"+error.line+"行,"+error.linepos+"个字符\n"+error.srcText+"\n"+s+"^"+"</XMP></font>"

		return r
}
function xslRunErr(exception) {
 return "<font face=Verdana size=2><font size=4>XSL实时错误</font>"+
 "<P><B>"+exception.description+"</B></P></font>"
}

function TransResult() {
	var sT=""
	if (oXML.parseError.errorCode!=0)
		sT=xslErr(oXML.parseError)
	else
	{
		if (oXSL.parseError.errorCode!=0)
			sT=xslErr(oXSL.parseError)
		else
		{
			try
			{
				sT=oXML.XMLDocument.transformNode(oXSL.XMLDocument); 
			}
			catch (exception)
			{
				sT=xslRunErr(exception)
			}
		}
	}	
	result.innerHTML = sT

}

function ActEncode(s1) {
//处理汉字的乱码问题
	if (typeof s1=="undefined") return ""
	if (s1==null) return ""
	var s2=s1
	if (s1.indexOf('%%')!=-1)
		var s2=left(s1,s1.indexOf('%%'))
	if (s1.indexOf('   ')!=-1)
		var s2=left(s1,s1.indexOf('  '))		
		return s2
}

function EnterRight(strRight) {
//strRight功能权限名
var strOperator=	parent.fstrOperatorDesc
if (strOperator=='系统主管')  return 0
var str1=SendHttp("public.asp?key=GetRight1",'<No>'+ strOperator+'</No><No1>'+strRight+'</No1>')
	if (str1=="")
	{
		alert("你没有此操作权限!")
		history.back()
	}
}


//显示报表列
function showRepCol(t,col){
	var iRows=t.rows.length-1
	var i
	for (i=0;i<=iRows;i++){
		t.rows(i).cells(col).style.display="block"
	}
}
//隐藏报表列
function hideRepCol(t,col){
	var iRows=t.rows.length-1
	var i
	for (i=0;i<=iRows;i++){
		t.rows(i).cells(col).style.display="none"
	}
}
function showWait() {
//显示等待

	document.write ('<div id=wait align=center style="BACKGROUND-COLOR: yellow; POSITION: absolute;LEFT: 30px; TOP: 120px; height: 50px; width: 400px">')
	document.write ('<BR>正在加载,请稍候......</div>')

}
*/
